/**
 * Copyright 2011 AJG van Schie
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.googlecode.julius.data.define;

import java.util.List;

import org.joda.time.LocalDate;

import com.googlecode.julius.utils.DateHelper;

public class DefineLog {

    private final String oldValue;
    private final String newValue;
    private final String field;
    private final String date;

    public DefineLog(final List<String> changelog) {
        super();
        this.date = changelog.get(0);
        // this.user = changelog[1];
        this.field = changelog.get(2);
        this.oldValue = changelog.get(3);
        this.newValue = changelog.get(4);
        // this.permanent = Integer.parseInt(changelog[5]);
    }

    public LocalDate getDate() {
        return DateHelper.parseToDate(date);
    }

    public String getOldValue() {
        return oldValue;
    }

    public String getNewValue() {
        return newValue;
    }

    public boolean isStatusChange() {
        return field.equals("status");
    }

    public boolean isEstimatedHoursChange() {
        return field.equals("estimatedhours");
    }

    public boolean isRemainingHoursChange() {
        return field.equals("remaininghours");
    }

    public boolean hasNewValue() {
        return getNewValue().trim().equals("");
    }

}
